<%@ page import="java.util.HashMap" %>
<%@ page import="com.jf.jsp.Monster" %><%--
  Created by IntelliJ IDEA.
  User: 22954
  Date: 2024/9/1
  Time: 17:47
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>JSTL学习</title>
</head>
<body>
<c:set scope="request" var="name" value="tom">
</c:set>
${name}<br/><br/>


<c:set scope="request" var="num1" value="12">
</c:set>
<c:set scope="request" var="num2" value="34">
</c:set>
<c:if test="${num1 < num2}">
    ${num1} < ${num2}<br/><br/>
</c:if>


<c:choose>
    <c:when test="${num1 > 5}">
        ${num1} 1<br/><br/>
    </c:when>
    <c:when test="${num1 > 10}">
        ${num1} 2<br/><br/>
    </c:when>
    <c:otherwise>
        ${num2}<br/><br/>
    </c:otherwise>
</c:choose>

<c:forEach var="i" begin="1" end="5" step="1">
    <li>下标${i}</li>
</c:forEach>
<br/>

<%
    String[] character = new String[]{"ab", "cd", "efg"};
    request.setAttribute("character", character);
%>
<c:forEach items="${requestScope.character}" var="ch">
    <li>${ch}</li>
</c:forEach>
<br/>

<%
    HashMap<String, Monster> monsters = new HashMap<>();
    monsters.put("m1", new Monster("幽魂", "头槌"));
    monsters.put("m2", new Monster("广智", "烈火斩"));
    request.setAttribute("monsters", monsters);
%>
<c:forEach items="${requestScope.monsters}" var="monster">
    <li>${monster.key} - ${monster.value.name} - ${monster.value.skill}</li>
</c:forEach>
</body>
</html>
